SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[SP_TDFLUJ_PROY_SEMA_Q01]
/*-----------------------------------------------------*/            
/*---Empresa               OFISIS S.A.              --*/            
/*---Cliente               CIA Hitepima       --*/            
/*---Sistema               Tesoreria        --*/            
/*---M¢dulo                Empresa         --*/            
/*---Programa              FLUJO DE CAJA PROY. MENSUAL--*/            
/*---Script                SP_TDFLUJ_PROY_SEMA_Q01.sql --*/            
/*---Nombre SP             SP_TDFLUJ_PROY_SEMA_Q01  --*/            
/*---Desarrollado por      Carlos Marquez   --*/            
/*---Fecha Creaci¢n        08/04/2005    --*/            
/*---Base Datos            SQL SERVER    --*/            
/*---Versi¢n               2000      --*/            
/*---Carga Plantilla Flujo Ejecutado    --*/            
/*-----------------------------------------------------*/            
/*-----------------------------------------------------*/            
/*---Modificado 1 por                   --*/            
/*---Fecha Modificaci¢n                 --*/             
/*---Detalle Modificaci¢n               --*/            
/*-------------------------------------------------------*/            
/*-------------------------------------------------------*/            
/*--- Drop Proc SP_TDFLUJ_PROY_SEMA_Q01          --*/            
/*--- Grant Execute on SP_TDFLUJ_PROY_SEMA_Q01 to public   --*/             
/*--- SP_TDFLUJ_PROY_SEMA_Q01 '01', 2006, 1     --*/            
/*--------------------------------------------------------*/            
@ISCO_EMPR  TD_VC_002,            
@INNU_ANIO  TD_IN_001,    
@INNU_SECU  TD_IN_001    
--With Encryption    
As            
            
Select         TDFLUJ_PROY_SEMA.CO_ARUB, TDFLUJ_PROY_SEMA.CO_RUBR, TDFLUJ_PROY_SEMA.CO_CLSU,     
  TTSUBR_FINA.DE_SUBR,     
  TDFLUJ_PROY_SEMA.IM_SALD_INIC,     
  TDFLUJ_PROY_SEMA.IM_CALC_SE01, TDFLUJ_PROY_SEMA.IM_CALC_SE02, TDFLUJ_PROY_SEMA.IM_CALC_SE03, TDFLUJ_PROY_SEMA.IM_CALC_SE04, 
    
  TDFLUJ_PROY_SEMA.IM_CALC_SE05, TDFLUJ_PROY_SEMA.IM_CALC_SE06, TDFLUJ_PROY_SEMA.IM_CALC_SE07, TDFLUJ_PROY_SEMA.IM_CALC_SE08, 
    
  TDFLUJ_PROY_SEMA.IM_CALC_SE09, TDFLUJ_PROY_SEMA.IM_CALC_SE10, TDFLUJ_PROY_SEMA.IM_CALC_SE11, TDFLUJ_PROY_SEMA.IM_CALC_SE12, 
 
  TDFLUJ_PROY_SEMA.IM_CALC_SE13, TDFLUJ_PROY_SEMA.IM_CALC_SE14, TDFLUJ_PROY_SEMA.IM_CALC_SE15, TDFLUJ_PROY_SEMA.IM_CALC_SE16, 
    
  TDFLUJ_PROY_SEMA.IM_CALC_SE17, TDFLUJ_PROY_SEMA.IM_CALC_SE18, TDFLUJ_PROY_SEMA.IM_CALC_SE19, TDFLUJ_PROY_SEMA.IM_CALC_SE20, 
    
  TDFLUJ_PROY_SEMA.IM_CALC_SE21, TDFLUJ_PROY_SEMA.IM_CALC_SE22, TDFLUJ_PROY_SEMA.IM_CALC_SE23, TDFLUJ_PROY_SEMA.IM_CALC_SE24,
  TDFLUJ_PROY_SEMA.IM_CALC_SE25, TDFLUJ_PROY_SEMA.IM_CALC_SE26, TDFLUJ_PROY_SEMA.IM_CALC_SE27, TDFLUJ_PROY_SEMA.IM_CALC_SE28, 
    
  TDFLUJ_PROY_SEMA.IM_CALC_SE29, TDFLUJ_PROY_SEMA.IM_CALC_SE30, TDFLUJ_PROY_SEMA.IM_CALC_SE31, TDFLUJ_PROY_SEMA.IM_CALC_SE32, 
    
  TDFLUJ_PROY_SEMA.IM_CALC_SE33, TDFLUJ_PROY_SEMA.IM_CALC_SE34, TDFLUJ_PROY_SEMA.IM_CALC_SE35, TDFLUJ_PROY_SEMA.IM_CALC_SE36,
  TDFLUJ_PROY_SEMA.IM_CALC_SE37, TDFLUJ_PROY_SEMA.IM_CALC_SE38, TDFLUJ_PROY_SEMA.IM_CALC_SE39, TDFLUJ_PROY_SEMA.IM_CALC_SE40, 
    
  TDFLUJ_PROY_SEMA.IM_CALC_SE41, TDFLUJ_PROY_SEMA.IM_CALC_SE42, TDFLUJ_PROY_SEMA.IM_CALC_SE43, TDFLUJ_PROY_SEMA.IM_CALC_SE44, 
    
  TDFLUJ_PROY_SEMA.IM_CALC_SE45, TDFLUJ_PROY_SEMA.IM_CALC_SE46, TDFLUJ_PROY_SEMA.IM_CALC_SE47, TDFLUJ_PROY_SEMA.IM_CALC_SE48,
  TDFLUJ_PROY_SEMA.IM_CALC_SE49, TDFLUJ_PROY_SEMA.IM_CALC_SE50, TDFLUJ_PROY_SEMA.IM_CALC_SE51, TDFLUJ_PROY_SEMA.IM_CALC_SE52, 
    
  TDFLUJ_PROY_SEMA.IM_CALC_SE53, TDFLUJ_PROY_SEMA.IM_CALC_SE54, TDFLUJ_PROY_SEMA.IM_CALC_SE55, TDFLUJ_PROY_SEMA.IM_CALC_SE56, 
    
  TDFLUJ_PROY_SEMA.IM_CALC_SE57, TDFLUJ_PROY_SEMA.IM_CALC_SE58, TDFLUJ_PROY_SEMA.IM_CALC_SE59, TDFLUJ_PROY_SEMA.IM_CALC_SE60, 
 
  'D' ST_AGRU_CLSU,    
  TTSUBR_FINA.NU_ORDE    
From TDFLUJ_PROY_SEMA, TTSUBR_FINA    
Where  
TDFLUJ_PROY_SEMA.CO_EMPR =  @ISCO_EMPR And    
TDFLUJ_PROY_SEMA.NU_ANIO =  @INNU_ANIO And    
TDFLUJ_PROY_SEMA.NU_SECU =  @INNU_SECU And    
    
TDFLUJ_PROY_SEMA.CO_EMPR = TTSUBR_FINA.CO_EMPR And    
TDFLUJ_PROY_SEMA.CO_ARUB = TTSUBR_FINA.CO_ARUB And    
TDFLUJ_PROY_SEMA.CO_RUBR = TTSUBR_FINA.CO_RUBR And    
TDFLUJ_PROY_SEMA.CO_CLSU = TTSUBR_FINA.CO_SUBR And     
ST_PROY = 'S'    
Union All     
Select TTSUBR_FINA.CO_ARUB, TTSUBR_FINA.CO_RUBR, TTSUBR_FINA.CO_SUBR,     
  TTSUBR_FINA.DE_SUBR,     
  0.00,     
  0.00, 0.00, 0.00, 0.00,     
  0.00, 0.00, 0.00, 0.00,     
  0.00, 0.00, 0.00, 0.00,   
  0.00, 0.00, 0.00, 0.00,     
  0.00, 0.00, 0.00, 0.00,     
  0.00, 0.00, 0.00, 0.00,    
  0.00, 0.00, 0.00, 0.00,     
  0.00, 0.00, 0.00, 0.00,     
  0.00, 0.00, 0.00, 0.00,    
  0.00, 0.00, 0.00, 0.00,     
  0.00, 0.00, 0.00, 0.00,     
  0.00, 0.00, 0.00, 0.00,    
  0.00, 0.00, 0.00, 0.00,     
  0.00, 0.00, 0.00, 0.00,     
  0.00, 0.00, 0.00, 0.00,     
  'D' ST_AGRU_CLSU,    
  TTSUBR_FINA.NU_ORDE    
From TTSUBR_FINA    
Where    
TTSUBR_FINA.CO_EMPR =  @ISCO_EMPR And    
ST_PROY = 'S' And    
Not Exists ( Select TDFLUJ_PROY_SEMA.CO_EMPR    
   From TDFLUJ_PROY_SEMA    
   Where    
   TDFLUJ_PROY_SEMA.NU_ANIO =  @INNU_ANIO And    
   TDFLUJ_PROY_SEMA.NU_SECU =  @INNU_SECU And    
       
   TDFLUJ_PROY_SEMA.CO_EMPR = TTSUBR_FINA.CO_EMPR And    
   TDFLUJ_PROY_SEMA.CO_ARUB = TTSUBR_FINA.CO_ARUB And    
   TDFLUJ_PROY_SEMA.CO_RUBR = TTSUBR_FINA.CO_RUBR And    
   TDFLUJ_PROY_SEMA.CO_CLSU = TTSUBR_FINA.CO_SUBR    
       
  )       
    
Order By TTSUBR_FINA.NU_ORDE          
    
    
RETURN            
/********************************* FIN ***********************************/


GO
